package com.example.ass7.animation;

import java.awt.Color;

import biuoop.DrawSurface;

import com.example.ass7.geometryprimitives.Counter;

/**
 * @author Meirav Ben Izhak
 */
public class EndScreen implements Animation {
    private final boolean won;
    private final Counter score;

    /**
     * @param won
     *            won
     * @param score
     *            score
     */
    public EndScreen(
        boolean won, Counter score) {
        this.won = won;
        this.score = score;
    }

    @Override
    public void doOneFrame(DrawSurface d,
            double dt) {
        if (this.won) {
            d.drawText(200, d.getHeight() / 2, "You Win! Your score is "
                    + this.score.getValue(), 32);
        } else {

            d.setColor(new Color(192, 192, 192));
            d.fillRectangle(0, 0, 800, 600);

            int size = 60;
            int x = 250;
            int y = d.getHeight() / 3 - 10;
            String message = "You Lost";

            d.setColor(Color.black);
            d.drawText(x, y, message, size);
            d.setColor(Color.red);
            d.drawText(x + 2, y + 1, message, size);
            d.setColor(Color.black);
            d.drawText(x + 5, y + 2, message, size);
        }

        String message = "Press space to continue";
        int size = 32;
        int x = 200;
        int y = d.getHeight() / 2 + 200;

        d.setColor(Color.black);
        d.drawText(x, y, message, size);
        d.setColor(new Color(23, 136, 208));
        d.drawText(x + 1, y + 1, message, size);
        d.setColor(Color.black);
        d.drawText(x + 3, y + 2, message, size);

        d.setColor(Color.black);
        d.drawText(10, 570, "Final score: "
                + this.score.getValue(), 13);
    }

    @Override
    public boolean shouldStop() {
        return Boolean.FALSE;
    }

}
